package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

type Config struct {
	Server     *Server     `yaml:"server"`
	Mysql      *Mysql      `yaml:"mysql"`
	Postgresql *Postgresql `yaml:"postgresql"`
	LogInfo    *LogInfo    `yaml:"log"`
	MongoDb    *MongoDb    `yaml:"mongodb"`
	RedisDb    *Redis      `yaml:"redis"`
	Jwt        *Jwt        `yaml:"jwt"`
}

func (c *Config) Init() {
	fileBytes, err := os.ReadFile("./config.yaml")
	if err != nil {
		panic(err.Error())
	}
	err = yaml.Unmarshal(fileBytes, c)
	if err != nil {
		panic(err.Error())
	}
}
